<!-- 外链,webview -->
<template>
	<view><web-view :src="webviewPath"></web-view></view>
</template>

<script>
export default {
	data() {
		return {
			webviewPath: '',
			mtime:0,
			celint:"",
			order_sn:""
		};
	},
	onLoad(e) {
		if(e.url){
			 this.order_sn=e.order_sn
			// this.mtime = 15
			// this.celint = setInterval(() => {
			// 	this.mtime--
			// 	if (this.mtime <= 0) {
			// 		clearInterval(this.celint)
			// 	}
			// }, 2000)
			
			// this.ispay()
			
			this.webviewPath = e.url
			
			return
		}
		this.webviewPath = this.$Route.query.webviewPath;
	},
	onHide() {
		if(this.order_sn){
			setTimeout(()=>{
				const pages = getCurrentPages();
				const prevPage = pages[pages.length - 2];
				console.log(prevPage)
				prevPage.$vm.$refs.paymodel.getValue(this.order_sn)
				uni.navigateBack()
			},3000)
		}
	},
	methods:{
		ispay(option) {
			return new Promise((resolve, reject) => {
				this.$http('v1.checkorderstatus',{
						order_sn:this.order_sn,
						type:1
					}).then(res => {
						
					if (res.data.pay_status == 1) {
							this.mtime = 0
							clearInterval(this.celint)
							let results= {
								result:{
									data:{
										order_sn:this.order_sn
									}
								}
							}
							this.$emit('payed', results);
					} else {
						if (this.mtime > 0) {
							setTimeout(() => {
								this.ispay(option).then(res => {
									if (res.data.pay_status == 1) {
										this.mtime = 0
										clearInterval(this.celint)
											let results= {
												result:{
													data:{
														order_sn:this.order_sn
													}
												}
											}
										this.$emit('payed', results);
									}
								})
							}, 2000)
						} else {
							this.paypay = false
								uni.showModal({
									content:'支付失败'
								})
								this.onClickOperate('','close',{})
						}
					}
		
				}).catch(res => {
					
				})
			})
		
		}
	}
};
</script>

<style></style>
